﻿var adultCounter = 0;
var childCounter = 0;
var fiftyplusCounter = 0;
var cjpStudentCounter = 0;
var drieDGlassesCounter = 0;

function previous() {
    history.go(-1);
}

function next() {
    adultCounter = parseInt(document.getElementById('inputTextAdult').value);
    childCounter = parseInt(document.getElementById('inputTextChild').value);
    fiftyplusCounter = parseInt(document.getElementById('inputText50plus').value);
    cjpStudentCounter = parseInt(document.getElementById('inputTextCJPStudent').value);

    var element = document.getElementById('inputText3DGlasses');

    if (element != null) {
        drieDGlassesCounter = parseInt(document.getElementById('inputText3DGlasses').value);
    }    

    if ((adultCounter + childCounter + fiftyplusCounter + cjpStudentCounter) > 0) {
        window.location = "pickseats.aspx?datetime=" + getQueryVariable("datetime") + "&roomnumber=" + getQueryVariable("roomnumber") + "&moviename=" + getQueryVariable("moviename") + "&adultcounter=" + adultCounter + "&childcounter=" + childCounter + "&50pluscounter=" + fiftyplusCounter + "&cjpstudentcounter=" + cjpStudentCounter + "&3dglassescounter=" + drieDGlassesCounter;
    
    } else {
        alert("U heeft nog geen kaarten gekozen.");
    }    
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}

function addAdultCounter() {
    adultCounter += 1;
    document.getElementById('inputTextAdult').value = adultCounter;
}

function substractAdultCounter() {
    if (adultCounter > 0) {
        adultCounter -= 1;
        document.getElementById('inputTextAdult').value = adultCounter;
    }    
}

function addChildCounter() {
    childCounter += 1;
    document.getElementById('inputTextChild').value = childCounter;
}

function substractChildCounter() {
    if (childCounter > 0) {
        childCounter -= 1;
        document.getElementById('inputTextChild').value = childCounter;
    }
}

function addFiftyplusCounter() {
    fiftyplusCounter += 1;
    document.getElementById('inputText50plus').value = fiftyplusCounter;
}

function substractFiftyplusCounter() {
    if (fiftyplusCounter > 0) {
        fiftyplusCounter -= 1;
        document.getElementById('inputText50plus').value = fiftyplusCounter;
    }
}

function addCJPStudentCounter() {
    cjpStudentCounter += 1;
    document.getElementById('inputTextCJPStudent').value = cjpStudentCounter;
}

function substractCJPStudentCounter() {
    if (cjpStudentCounter > 0) {
        cjpStudentCounter -= 1;
        document.getElementById('inputTextCJPStudent').value = cjpStudentCounter;
    }
}

function add3DGlassesCounter() {
    drieDGlassesCounter += 1;
    document.getElementById('inputText3DGlasses').value = drieDGlassesCounter;
}

function substract3DGlassesCounter() {
    if (drieDGlassesCounter > 0) {
        drieDGlassesCounter -= 1;
        document.getElementById('inputText3DGlasses').value = drieDGlassesCounter;
    }
}